using System;
using System.Globalization;
using FileHelpers;

namespace GATCreditAppExportAndUpdateNav
{
    [DelimitedRecord(",")]
    public class DocumentStore
    {
        public string DocType;
        public string CustomerNo;
        public string CustomerName;
        public string DocumentDate;
        public string Url;

        public DateTime GetDocumentDate()
        {
            if(!string.IsNullOrEmpty(DocumentDate))
            {
                string dateStr = DocumentDate.Substring(0, DocumentDate.Trim().IndexOf(' ')).Trim();
                string day = dateStr.Substring(0, dateStr.IndexOf('/'));
                string month = dateStr.Substring(dateStr.IndexOf('/')+1, dateStr.LastIndexOf('/') - dateStr.IndexOf('/')-1);
                string year = dateStr.Substring(dateStr.LastIndexOf('/') + 1);
                if(year.Length == 2)
                {
                    year = "20" + year;
                }
                return new DateTime(int.Parse(year),int.Parse(month),int.Parse(day));
            }
            return DateTime.MinValue;
        }
    }
}